package com.cqc.jdk8.Jlang.object;

import java.text.DateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;

public class AThread extends Thread {

    private final Object lock;

    public AThread(Object lock) {
        this.lock = lock;
    }

    @Override
    public void run() {
        synchronized (lock) {
            System.out.println(Thread.currentThread().getName() + "..." + DateFormat.getDateTimeInstance().format(new Date()));
            try {
                lock.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "..." + DateFormat.getDateTimeInstance().format(new Date()));
        }
    }
}